﻿using System.Linq;
using AB.ServiceDirectory.Commons.DataFilters;
using AB.ServiceDirectory.Dao;
using AB.ServiceDirectory.Entities;

namespace AB.ServiceDirectory.BO
{
    /// <summary>
    /// ASupportingMaterialBO
    /// </summary>
    public sealed class ASupportingMaterialBO
    {
        /// <summary>
        /// Prevents a default instance of the <see cref="ASupportingMaterialBO"/> class from being created.
        /// </summary>
        private ASupportingMaterialBO()
        {
        }

        /// <summary>
        /// Gets the list supporting material.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <param name="sortType">Type of the sort.</param>
        /// <param name="startRowIndex">Start index of the row.</param>
        /// <param name="maxRows">The max rows.</param>
        /// <returns></returns>
        public static IQueryable<SupportingMaterial> GetListSupportingMaterial(ASupportingMaterialFilter filter,
                                                                               string sortType, int startRowIndex,
                                                                               int maxRows)
        {
            return ASupportingMaterialDao.GetListSupportingMaterial(filter, sortType, startRowIndex, maxRows);
        }

        /// <summary>
        /// Gets the list supporting material count.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        public static int GetListSupportingMaterialCount(ASupportingMaterialFilter filter)
        {
            return ASupportingMaterialDao.GetListOrganizationCount(filter);
        }

        /// <summary>
        /// Gets the supporting material by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public static SupportingMaterial GetSupportingMaterialById(int id)
        {
            return ASupportingMaterialDao.GetSupportingMaterialById(id);
        }

        /// <summary>
        /// Updates the status.
        /// </summary>
        /// <param name="supportingMaterialId">The supporting material id.</param>
        /// <param name="active">if set to <c>true</c> [active].</param>
        /// <returns></returns>
        public static bool UpdateStatus(int supportingMaterialId, bool active)
        {
            return ASupportingMaterialDao.UpdateStatus(supportingMaterialId, active);
        }

        /// <summary>
        /// Loads all type.
        /// </summary>
        /// <returns></returns>
        public static IQueryable<SupportingMaterial> LoadAllType()
        {
            return ASupportingMaterialDao.FindAllData();
        }

        /// <summary>
        /// Inserts the supporting material.
        /// </summary>
        /// <param name="supportingMaterial">The supporting material.</param>
        /// <returns></returns>
        public static bool InsertSupportingMaterial(SupportingMaterial supportingMaterial)
        {
            var supportingMaterialDao = new ASupportingMaterialDao();
            return supportingMaterialDao.InsertSupportingMaterial(supportingMaterial);
        }

        /// <summary>
        /// Updates the supporting material.
        /// </summary>
        /// <param name="supportingMaterial">The supporting material.</param>
        /// <returns></returns>
        public static bool UpdateSupportingMaterial(SupportingMaterial supportingMaterial)
        {
            var supportingMaterialDao = new ASupportingMaterialDao();
            return supportingMaterialDao.UpdateSupportingMaterial(supportingMaterial);
        }

        /// <summary>
        /// Sets the supporting material status.
        /// </summary>
        /// <param name="supportingMaterialId">The supporting material id.</param>
        /// <param name="status">if set to <c>true</c> [status].</param>
        public static void SetSupportingMaterialStatus(int supportingMaterialId, bool status)
        {
            var supportingMaterialDao = new ASupportingMaterialDao();
            supportingMaterialDao.SetSupportingMaterialStatus(supportingMaterialId, status);
        }
    }
}